new Vue({
    el: '#app',
    data: function() {
      return { 
            visible: false ,
            message:''
        }
    },
    watch:{
        message(val){
            console.log(val)
            if (val!=''){
                this.visible = true
            }
        }
    },
    computed:{
        is_electron(){
            return !!window.ipcRenderer
        }
    },
    methods:{
        
        runScript(scriptName){
            this.message = scriptName
            this.visible = true
            if(!this.is_electron) return
            
            window.ipcRenderer.runScript(scriptName)
            .then(output => {
                this.message = output;

            })
            .catch(err => {
                this.message = `Error: ${err}`
              
            });

            
        }
    }

})